{	Problem: http://codeforces.ru/problemset/problem/80/D
	Verdict: Accepted
}
var i,n:longint; a,b:int64; r:double;
begin
read(n);
for i:=1 to n do begin
  read(a,b);
  if b=0 then begin
    writeln(1);
    continue;
  end;
  if a=0 then begin
    writeln('0.5');
    continue;
  end;
  r:=1;
  if a<=4*b then r:=a*b+a*a/8 else r:=2*a*b-b*b*2;
  r:=r/(a*b*2);
  writeln(r:0:9);
end;
end.